package eventplanner.ejb.dao;

import eventplanner.entities.Feed;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

@Stateless
public class FeedDao {

	@PersistenceContext
	private EntityManager em;

	public List getAllIdsAndNamesOfPublicFeeds() {
		return em.createQuery("select f.id, f.name from Feed f where f.isPublic = true").getResultList();
	}

	public List getAllIdsAndNamesOfAllFeeds() {
		return em.createQuery("select f.id, f.name from Feed f").getResultList();
	}

	public void persist(Feed feed) {
		em.persist(feed);
	}
}
